#Include 'Protheus.ch'

User Function CT5TOZB5()
	
	Local	aFiliais	:=	{'01','02','03','50'}
	Local	nX			:=	0
	Local	aArea		:=	GetArea()
	
	DbSelectArea('ZB5')
	
	For nX	:=	1 To Len(aFiliais)
		
		DbSelectArea('CT5')
		DbSetOrder(1)
		DbGotop()
		
		While .Not. CT5->(Eof())
			
			ZB5->(RecLock('ZB5',.T.))
			
			ZB5->ZB5_FILIAL	:=	aFiliais[nX]
			ZB5->ZB5_TABELA	:=	'2'
			ZB5->ZB5_CODIGO	:=	AllTrim(CT5->CT5_LANPAD) + '/' + AllTrim(CT5->CT5_SEQUEN)
			ZB5->ZB5_DESCR	:=	CT5->CT5_DESC
			ZB5->ZB5_REFER	:= Date()
			
			ZB5->(MsUnlock())
			
			CT5->(DbSkip())
			
		EndDo
		
	Next nX
	
	RestArea(aArea)
	
	Alert('Concluido !!!!')
	
Return

